package org.magnerfuller.imtoolkit.server.modules.event;

import org.magnerfuller.imtoolkit.server.modules.ModuleLoader;
import org.magnerfuller.imtoolkit.util.StanzaParse;

/**
 * The class ModuleLoaderEvent provides information on events occurring
 * in a module loader.
 *
 */
public class ModuleLoaderEvent {
  
  /** source -- The source of the event */
  private ModuleLoader source;
  
  /** type -- The type of the event */
  private int type;
  
  /** moduleProps -- Properties associated with a module, if relevant */
  private StanzaParse moduleProps;

  /** MODULE_LOAD -- Indicates that a module load event occurred */
  public static final int MODULE_LOAD = 0;

  /** MODULE_WITH_PROPS_LOAD -- Indicates that a module with properties was loaded */
  public static final int MODULE_WITH_PROPS_LOAD = 1;

  /**
   * Constructor
   * 
   * @param source -- The source of the event
   * @param type -- The type of the event
   */
  public ModuleLoaderEvent(ModuleLoader source, int type) {
    this.source = source;
    this.type = type;
  }//ModuleLoaderEvent

  /**
   * Constructor
   * 
   * @param source -- The source of the event
   * @param type -- The type of the event
   * @param moduleProps -- Properties associated with a loaded module
   */
  public ModuleLoaderEvent(ModuleLoader source, int type, StanzaParse moduleProps) {
    this(source, type);
    this.moduleProps = moduleProps;
  }//ModuleLoaderEvent

  /**
   * Get the source of the event.
   * 
   * @return the source
   */
  public ModuleLoader getSource() {
    return source;
  }//getSource

  /**
   * Get the type of the event.
   * 
   * @return the type
   */
  public int getType() {
    return type;
  }//getType
  
  /**
   * Get the properties associated with the loaded module, if any.
   * 
   * @return the properties as a Stanza Parse, or null if not relevant
   */
  public StanzaParse getModuleProps() {
    return moduleProps;
  }//getModuleProps

}//ModuleLoaderEvent
